<?php
/**
* 功能: 首页更多显示
* 创建日期:Tue Dec 20 10:01:50 CST 2011
* 最后更新:
* 作者: slash
*/

class index_more extends TheAdmin {

	public $pageSize = 10;
	function index_more() {
	}

	public function set()
	{
		$this->TheAdmin();
		$this->admin_user_id = $this->userRequest->get('admin_user_id');
		//取得用户对于该类的权限
		$user_p = $this->get_user_popedom_by_class_name(__CLASS__);
		$class_p_arr = $this->show_p();
		//取得该类的权值数组
		$class_method = $class_p_arr['class_method'];
		//取得用户操作菜单
		$menu = array();
		foreach ($class_method as $k=>$v)
		{
			if( (parse_power($user_p,$v[2]) && (isset($v[3]) ?$v[3] :false)) || IS_ROOT)
			{
				array_push($menu,array('url'=>"?c=".__CLASS__."&m={$v[0]}",'title'=>$v[1]));
			}
		}
		$group_state_arr = array(1=>'正常',0=>'异常');
		//用户有权菜单生成 可以添加其他操作
		$this->smarty->assign('menus',$menu);
		$this->smarty->assign("main_menus",$this->get_user_menus());
		$this->tplFile = "index_more.tpl";
	}
	public function __construct()
	{
		$this->index_more();
	}
	function show(){
		//$this->tplFile = "admin_group.tpl";
	}

	function zy_sell_more()
	{
		global $notice_time;
		$db =Factory::getDB('zy_sell');
		$col = "add_time";
		$where = time()."< finish_time and finish_time < ".(3600*24*$notice_time+time());
		$rowNo = $db->getSumNumber('zy_sell',$where);
		//数据库执行sql语句出错
		//取得错误的sql语句
		//$error_sql = end($this->db->getDebugMsg());
		//echo $error_sql;exit();
		if( 0 > $rowNo) goToIndex($rowNo);
		//分页
		$page = Factory::getBaseClass('pagination');
		$page->set($rowNo,$this->pageSize);
		$numrows = $this->pageSize;
		$offset  = $page->getSqlMove();
		$arr = $db->getAll($where,$col,$numrows,$offset);
		//print_r($arr);
		//数据库执行select语句出错
		//取得错误的sql语句
		/*$error_sql = end($db->getDebugMsg());
		echo $error_sql;*/
		if(0 > $arr ) goToIndex($arr);

		$this->smarty->assign('arr',$arr);
		admin_log($this->admin_user_id,__METHOD__,'查看',1);
		//默认方法
		$this->smarty->assign("page_footer",$page->getFooter().$page->getJumpPage());
		$this->smarty->assign('act','sell_list');
		$this->smarty->display($this->tplFile);
	}
	
	
	
	function week_job()
	{
		//本周需要协调的事宜
		$this_w_db = Factory::getDB('zy_coordinate');
		$week_where = "week_time='".date('Y')."-".date('W')."'";
		$week_arr = $this_w_db->getAll($week_where);
		//print_r($week_arr);
		$this->smarty->assign('week_arr',$week_arr);
		$this->smarty->assign('act','week_job');
		$this->smarty->display($this->tplFile);
	}




	public function show_p()
	{
		//该方法为，提供用户使用方法定义，非web用户权限相关不用写
		return array(
		/* 定义该类中文名称*/
		'class_name'=>array(__CLASS__,'首页更多'),
		'class_method' =>array(
		//array（方法名，中文解释，权值,是否为菜单）
		'zy_sell_more'  => array('zy_sell_more','合同列表',1,true),
		'week_job'  => array('week_job','本周协调事宜',2,true),
		)
		);
	}
}